package selfStudy.demo2.iotest;

import selfStudy.demo2.iotest.domain.Student1;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Test6 {
    public static void main(String[] args) throws IOException {
        //请按以下要求编写程序：
        //		1).定义一个学员类，有以下属性：姓名、性别、年龄、分数
        //		  无参、全参构造方法，get/set方法
        //		2).定义main()方法，定义一个存储Student的集合，并初始化一些数据：
        //			List<Student> stuList = new ArrayList<>();
        //			stuList.add(new Student(“迪丽热巴”,”女”,18,99);
        //			stuList.add(new Student(“古力娜扎”,”女”,19,98);
        //			stuList.add(new Student(“周杰伦”,”男”,20,88);
        //			stuList.add(new Student(“蔡徐坤”,”男”,19,78);
        //			/*
        //			定义一个字符缓冲输出流BufferedWriter，将学员信息写入到”test3_4.txt”中，
        //            每个学员信息占一行，每个字段之间用,符号隔开，例如：
        //				迪丽热巴,女,18,99
        //				古力娜扎,女,19,98
        //				周杰伦,男,20,88
        //				蔡徐坤,男,19,78
        List<Student1> stulist = new ArrayList<>();
        stulist.add(new Student1("迪丽热巴","女","18","99"));
        stulist.add(new Student1("古力娜扎","女","18","98"));
        stulist.add(new Student1("周杰伦","男","20","88"));
        stulist.add(new Student1("蔡徐坤","男","19","78"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("day12\\test3_4.txt"));
        for (Student1 student : stulist) {
            bw.write(student.getName()+","+student.getGender()+","+student.getAge()+","+student.getSorce()+"\r\n");
        }
        //刷新流
        bw.flush();
        //释放资源
        bw.close();
    }
}
